package homewoek1月4号.demo3.d5;

import org.apache.commons.io.FileUtils;

import java.io.File;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        byte[] arr = FileUtils.readFileToByteArray(new File("src/czxy/com/demo3/d5/timg.jpg"));
        int len=4*1024;
        int start=0;
        int a=0;
        while (start<=arr.length-1){
            a++;
            if (start+len<=arr.length-1){
                FileUtils.writeByteArrayToFile(new File("src/czxy/com/demo3/d5/"+a+".jpg"),arr,start,len,false);
            }else {
                FileUtils.writeByteArrayToFile(new File("src/czxy/com/demo3/d5/"+a+".jpg"),arr,start,arr.length-start,false);
            }
            start+=len;
        }
        for (int i = 1; i <=9 ; i++) {
            byte[] bytes = FileUtils.readFileToByteArray(new File("src/czxy/com/demo3/d5/" + i + ".jpg"));
            FileUtils.writeByteArrayToFile(new File("src/czxy/com/demo3/d5/xx.jpg"),bytes,true);
        }
    }
}
